package com.vim.modules.mall.service.impl;

import com.github.pagehelper.PageInfo;
import com.vim.common.utils.AssertUtils;
import com.vim.modules.mall.model.base.CommonPage;
import com.vim.modules.mall.model.base.MallResponseEntity;
import com.vim.modules.mall.model.base.Page;
import com.vim.modules.mall.model.base.PageConvertUtils;
import com.vim.modules.mall.model.mallOrder.MallOrder;
import com.vim.modules.mall.model.mallOrder.MallOrderOperateHistory;
import com.vim.modules.mall.model.mallOrder.MallOrderUnion;
import com.vim.modules.mall.service.MallOrderService;
import com.vim.modules.mall.service.remote.RemoteMallOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @作者 Administrator
 * @时间 2020-10-04 19:22
 * @版本 1.0
 */
@Service
public class MallOrderServiceImpl implements MallOrderService{

    @Autowired
    private RemoteMallOrderService remoteMallOrderService;

    /**
     * 获取订单列表
     */
    @Override
    public PageInfo<MallOrder> orderList(Page page) {
        MallResponseEntity<CommonPage<MallOrder>> result = remoteMallOrderService.orderList(page.getPageNo(), page.getPageSize());
        AssertUtils.assertAjaxOK(result);
        return PageConvertUtils.convert(result.getData());
    }

    /**
     * 获取订单详情
     * @param orderId 订单id
     */
    @Override
    public MallOrderUnion orderDetail(Long orderId) {
        MallResponseEntity<MallOrderUnion> result = remoteMallOrderService.orderDetail(orderId);
        AssertUtils.assertAjaxOK(result);
        return result.getData();
    }

    /**
     * 订单发货
     * @param orderId 订单id
     */
    @Override
    public void orderDelivery(Long orderId) {
        MallResponseEntity result = remoteMallOrderService.orderDelivery(orderId);
        AssertUtils.assertAjaxOK(result);
    }
}
